package com.bestow.lease.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestow.common.annotation.Log;
import com.bestow.common.core.controller.BaseController;
import com.bestow.common.core.domain.AjaxResult;
import com.bestow.common.enums.BusinessType;
import com.bestow.lease.domain.PrjPlanLn;
import com.bestow.lease.service.IPrjPlanLnService;
import com.bestow.common.utils.poi.ExcelUtil;
import com.bestow.common.core.page.TableDataInfo;

/**
 * 项目方案子项目Controller
 * 
 * @author liliu
 * @date 2022-12-07
 */
@RestController
@RequestMapping("/lease/planLn")
public class PrjPlanLnController extends BaseController
{
    @Autowired
    private IPrjPlanLnService prjPlanLnService;

    /**
     * 查询项目方案子项目列表
     */
    @PreAuthorize("@ss.hasPermi('lease:planLn:list')")
    @GetMapping("/list")
    public TableDataInfo list(PrjPlanLn prjPlanLn)
    {
        startPage();
        List<PrjPlanLn> list = prjPlanLnService.selectPrjPlanLnList(prjPlanLn);
        return getDataTable(list);
    }

    /**
     * 导出项目方案子项目列表
     */
    @PreAuthorize("@ss.hasPermi('lease:planLn:export')")
    @Log(title = "项目方案子项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PrjPlanLn prjPlanLn)
    {
        List<PrjPlanLn> list = prjPlanLnService.selectPrjPlanLnList(prjPlanLn);
        ExcelUtil<PrjPlanLn> util = new ExcelUtil<PrjPlanLn>(PrjPlanLn.class);
        util.exportExcel(response, list, "项目方案子项目数据");
    }

    /**
     * 获取项目方案子项目详细信息
     */
    @PreAuthorize("@ss.hasPermi('lease:planLn:query')")
    @GetMapping(value = "/{planLnId}")
    public AjaxResult getInfo(@PathVariable("planLnId") Long planLnId)
    {
        return AjaxResult.success(prjPlanLnService.selectPrjPlanLnByPlanLnId(planLnId));
    }

    /**
     * 新增项目方案子项目
     */
    @PreAuthorize("@ss.hasPermi('lease:planLn:add')")
    @Log(title = "项目方案子项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PrjPlanLn prjPlanLn)
    {
        return toAjax(prjPlanLnService.insertPrjPlanLn(prjPlanLn));
    }

    /**
     * 修改项目方案子项目
     */
    @PreAuthorize("@ss.hasPermi('lease:planLn:edit')")
    @Log(title = "项目方案子项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PrjPlanLn prjPlanLn)
    {
        return toAjax(prjPlanLnService.updatePrjPlanLn(prjPlanLn));
    }

    /**
     * 删除项目方案子项目
     */
    @PreAuthorize("@ss.hasPermi('lease:planLn:remove')")
    @Log(title = "项目方案子项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{planLnIds}")
    public AjaxResult remove(@PathVariable Long[] planLnIds)
    {
        return toAjax(prjPlanLnService.deletePrjPlanLnByPlanLnIds(planLnIds));
    }
}
